﻿<%--
 *  File:    ActivityManageFileUpload.jsp
 *  @Author: KentZhong
 *  Date:    2009-10-27 15:16:29
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.foundation.DefaultParams" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
   String strModuleName = "SFE";
   String contextPath = request.getContextPath();
%>



<%@ include file="/inc/PageDefault.inc" %>
<%@include file="/inc/Print.inc"%>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_activitymanagefileupload"/>
	<%
String strIsUpload=request.getParameter("isupload");
if("Y".equals(strIsUpload))
{
%>
<script>
parent.page_setfileid	('<custom:write property="detailno"/>','<custom:write property="activitymanagefilesid"/>');
</script>
<%
}
String strIsDelete=request.getParameter("isdelete");
if("Y".equals(strIsDelete))
{
%>
<script>
parent.page_setfileid	('<custom:write property="detailno"/>',' ');
</script>
<%
}
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script>
	function selectFile()
	{
	  var val = cform.uploadfile.value;
	  var fn = val.substring(val.lastIndexOf('\\')+1,val.length);
	  if(fn.length == val.length)
	    fn = val.substring(val.lastIndexOf('\/')+1,val.length);
	  cform.originalfilename.value=fn;
	}
	function page_upload()
{  
  if(isEmpty(cform.uploadfile.value))
    return;
  var pname = cform.uploadfile.value;
  var re = /.exe$|.dll$|.ocx$|.js$/ig; 
  if(pname.toUpperCase().match(re) != null)
  {
    alert("<%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Name",false)) %>");
    return;
  }  
  if (pname.indexOf("\\")!=-1)
    pname = pname.substring(pname.lastIndexOf("\\")+1,pname.length);
  cform.originalfilename.value = pname;
  var iLastPoint=pname.lastIndexOf(".");
  if(iLastPoint!=-1)
  	cform.filesuffix.value=pname.substring( iLastPoint+1,pname.length);

 // cform.enctype="multipart/form-data";
  cform.actionname.value="upload";
  isRunning = true;
  cform.submit();
}
function page_delete()
{
	 cform.actionname.value="delete";
  isRunning = true;
  cform.submit();
}
function page_download()
{
	cform.target="downloadframe";
	cform.actionname.value="download";
  
  cform.submit();
}
</script>
</head>

<body>
<iframe name="downloadframe" style="display:none" ></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher" enctype="multipart/form-data">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td>
		<input type="hidden" name="pagename" value="p_activitymanagefileupload">
    <input type="hidden" name="actionname">
    <custom:hidden property="activitymanagefilesid"/>
    <custom:hidden property="detailno"/>
    <custom:hidden name="fileinfo" property="filename"/>
    <custom:hidden name="fileinfo" property="originalfilename"/>
    <custom:hidden  property="baseorskutype"/>
    <custom:hidden  property="feedbackstatus"/>
    
    
    <%
    Integer oStatus=(Integer)pageContext.getAttribute("feedbackstatus");
    
    HashMap fileinfo=(HashMap)pageContext.getAttribute("fileinfo");
    if(fileinfo==null)
    	fileinfo=new HashMap();
    if(!fileinfo.isEmpty())
    {	
    %>	
    <custom:hidden name="fileinfo" property="uploadpath"/>	
    <a href="javascript:page_download();"><custom:write name="fileinfo" property="originalfilename"/></a>
    <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
    	<%if(oStatus!=null && oStatus.intValue()==10){%>
    	
  <%}
  }else{%> 
  	<input type="hidden" name="uploadpath" value="<%=DefaultParams.findParam("uploadfilepath")%>"/>
  	<input type="hidden" name="filesuffix" value=""/>
  	<input type="file" name="uploadfile" onclick="javascript:uploadfile.focus()" onfocus="javascript:selectFile()" size="20">
  	<a onclick="page_upload();"><custom:button type="1" label="L_Upload" imgsrc="delete.gif" border="0" style="width:60"/></a>
  	<%if(oStatus==null || oStatus.intValue()==10){%>
  	
  <%}
  }%>	
  </td>
</tr>
</table>
</form>
</body>
</html>		
	